(function($, XDE) {
	class XbzInput {
		constructor() {
			this.defaultFields = {
				// 基础信息
				id: "",
				pid: "0",
				tag: "input",
				drag: 1,
				// 配置信息
				config: {
					fieldId: "",
					fieldName: "",
					fieldValue: "",
					fieldPlaceholder: "",
					fieldReadonly: false,
					fieldRequired: false,
					fieldExpression: ""
				}
			};
		}

		// 构建Node
		buildNode(node, isNew) {
			if (XDE.util.isNull(node)) {
				node = {};
			}

			// 深拷贝
			$.extend(true, node, this.defaultFields);

			// 新节点
			if (isNew === true || XDE.util.isNull(node.id)) {
				node.id = XDE.util.uuid();
			}
			return node;
		}

		// 创建元素
		createElement(node) {
			// 构建Node
			node = this.buildNode(node);

			// 创建元素
			var element = document.createElement("div");
			element.setAttribute("class", "layui-form-item");
			element.setAttribute("x-id", node.id);
			element.setAttribute("x-tag", node.tag);
			element.setAttribute("x-drag", node.drag);

			// 标题区域
			var labelElement = document.createElement("label");
			labelElement.setAttribute("class", "layui-form-label");
			labelElement.appendChild(document.createTextNode("单行文本框"));
			element.appendChild(labelElement);

			// 输入区域
			var inputBlockDiv = document.createElement("div");
			inputBlockDiv.setAttribute("class", "layui-input-block");

			// 输入框input
			var inputElement = document.createElement("input");
			inputElement.setAttribute("name", XDE.util.getValue(node.fieldName, ""));
			inputElement.setAttribute("placeholder", XDE.util.getValue(node.fieldPlaceholder, ""));
			inputElement.setAttribute("type", "text");
			inputElement.setAttribute("class", "layui-input");
			inputElement.setAttribute("autocomplete", "off");
			inputElement.setAttribute("readonly", XDE.util.getValue(node.fieldReadonly, "false"));
			inputBlockDiv.appendChild(inputElement);

			element.appendChild(inputBlockDiv);

			// 返回结果
			return {
				node: node,
				element: element
			};
		}

	}

	// 注册组件
	XDE.ass.put("input", new XbzInput());
})(XbzDesigner.$, XbzDesigner);
